{% extends "base.html" %}

{% block css %}
    <style>
        tr:hover {
            background-color: #e7e7e7;
        }

        #cen {
            text-align: center;
        }

        a:hover {
            color: red;
        }

        .btn-primary:hover {
            color: red;
        }

        .plan-name {
            max-width: 150px;
            word-wrap: break-word;
            text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
        }

        .plan-name:hover {
            white-space: normal;
            overflow: auto;
        }

        .btn {
            padding: 6px 18px;
        }

        #plan-content {
            text-align: center;
            max-width: 50px;
            word-wrap: break-word;
            text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
        }
    </style>
{% endblock %}

{% block nav %}
    {% for object in model_list %}
        <li><a href="{{ object.url }}"><i class="{{ object.icon }}"></i>{{ object.model_name }}</a>
        </li>

    {% endfor %}

{% endblock %}

{% block crumbs %}
    <div class="row">
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li class="active">
                    <a class="this-page" href="{% url 'base:performance_report' %}">性能测试</a>
                </li>
                <li class="active">
                    <a class="this" href="{% url 'base:performance_report' %}">聚合报告</a>
                </li>
                <li class="active">
                    <a class="this">历史数据</a>
                </li>
            </ol>

        </div>
    </div>
{% endblock %}

{% block body %}
    <div class="row">
        <div class="col-md-12">
            <div class="panel">
                <div class="panel-heading">
                    <a class="this" href="{% url 'base:performance' %}" style="margin-left: 5%">Locust页面</a>
                    <a class="this" href="{% url 'base:performance_report' %}"
                       style="margin-left: 3%;border-bottom: 2px solid #409EFF;">聚合报告</a>
                    <a class="btn btn-primary" href="{% url 'base:performance_real' %}"
                       style="margin-left: 50%;margin-right: 3%">实时数据</a>
                    <a class="btn btn-primary">历史数据</a>
                    <a href="{% url 'base:performance_delete' %}" class="btn btn-danger">清除数据</a>
                </div>
                <div class="spinner"></div>
                <div class="panel-body">
                    <h4 class="col-sm-2 control-label">历史数据</h4>
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th id="cen">Label</th>
                            <th id="cen">Type</th>
                            <th id="cen">#样本</th>
                            <th id="cen">平均值</th>
                            <th id="cen">中位数</th>
                            <th id="cen">最小值</th>
                            <th id="cen">最大值</th>
                            <th id="cen">异常次数</th>
                            <th id="cen">吞吐量</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for stats in info %}
                            {% for stat in stats %}
                                <tr>
                                    <td id="cen" class="plan-name">{{ stat.name }}</td>
                                    <td id="cen">{{ stat.method }}</td>
                                    <td id="cen">{{ stat.num_requests }}</td>
                                    <td id="cen">{{ stat.avg_response_time }}</td>
                                    <td id="cen">{{ stat.median_response_time }}</td>
                                    <td id="cen">{{ stat.min_response_time }}</td>
                                    <td id="cen">{{ stat.max_response_time }}</td>
                                    <td id="cen">{{ stat.num_failures }}</td>
                                    <td id="cen">{{ stat.current_rps }}</td>

                                </tr>
                            {% endfor %}
                        {% endfor %}
                        </tbody>
                    </table>
                    {#                    <div id="input-timed">#}
                    {#                        <p><span style="margin: 5px 10%">状态：{{ info.state }}</span><span style="margin-right:10%">Total RPS: {{ info.total_rps }}</span><span#}
                    {#                                style="margin-right:10%">失败率: {{ info.fail_ratio }}</span><span#}
                    {#                                style="margin-right:10%">用户数: {{ info.user_count }}</span></p>#}
                    {#                        <p><span#}
                    {#                                style="margin: 5px 10%">50% 百分比：{{ info.current_response_time_percentile_50 }}</span><span#}
                    {#                                style="margin-right:10%">50% 百分比: {{ info.current_response_time_percentile_95 }}</span>#}
                    {#                        </p>#}
                    {#                    </div>#}

                </div>

            </div>

        </div>
    </div>
{% endblock %}

{% block javascript %}
    <script>

        //删除
        function delete_btn() {
            if (window.confirm("你确定要删除吗？")) {
                return true;//确定返回真
            }
            else {
                return false;//取消返回假
            }
        }

    </script>
{% endblock %}
